package org.mspring.mlog.entity.bbs;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.mspring.mlog.entity.security.User;

/**
 * 
 * @author Gao Youbo
 * @since 2013年9月3日
 */
@Entity
@Table(name = "topic_reply")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class TopicReply implements Serializable {

    /**
     * 
     */
    private static final long serialVersionUID = -4991835004031343319L;

    // 回帖基本信息
    private Long id;
    private String content;
    private User author;
    private String postIp;
    private String agent;
    private Date createTime;

    // 回帖关联信息
    private Topic topic;

    // 引用
    private TopicReply quote; // 引用评论对象
    private Long quoteUser; // 引用用户编号
    private String quoteUserName; // 引用用户名
    private String quoteUserAlias; // 引用用户名
    private String quoteContent; // 引用内容

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name = "content", nullable = false)
    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    @ManyToOne(fetch = FetchType.EAGER, optional = false, targetEntity = User.class)
    @JoinColumn(name = "author", nullable = false)
    public User getAuthor() {
        return author;
    }

    public void setAuthor(User author) {
        this.author = author;
    }

    @Column(name = "post_ip", nullable = false)
    public String getPostIp() {
        return postIp;
    }

    public void setPostIp(String postIp) {
        this.postIp = postIp;
    }

    @Column(name = "agent", nullable = false)
    public String getAgent() {
        return agent;
    }

    public void setAgent(String agent) {
        this.agent = agent;
    }

    @Column(name = "create_time", length = 30, nullable = false)
    @Temporal(TemporalType.TIMESTAMP)
    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @ManyToOne(fetch = FetchType.LAZY, optional = false, targetEntity = Topic.class)
    @JoinColumn(name = "topic", nullable = false)
    public Topic getTopic() {
        return topic;
    }

    public void setTopic(Topic topic) {
        this.topic = topic;
    }

    @ManyToOne(fetch = FetchType.LAZY, optional = false, targetEntity = TopicReply.class)
    @JoinColumn(name = "quote")
    public TopicReply getQuote() {
        return quote;
    }

    public void setQuote(TopicReply quote) {
        this.quote = quote;
    }

    @Column(name = "quote_user", length = 30)
    public Long getQuoteUser() {
        return quoteUser;
    }

    public void setQuoteUser(Long quoteUser) {
        this.quoteUser = quoteUser;
    }

    @Column(name = "quote_name")
    public String getQuoteUserName() {
        return quoteUserName;
    }

    public void setQuoteUserName(String quoteUserName) {
        this.quoteUserName = quoteUserName;
    }

    @Column(name = "quote_alias")
    public String getQuoteUserAlias() {
        return quoteUserAlias;
    }

    public void setQuoteUserAlias(String quoteUserAlias) {
        this.quoteUserAlias = quoteUserAlias;
    }

    @Column(name = "quote_content")
    public String getQuoteContent() {
        return quoteContent;
    }

    public void setQuoteContent(String quoteContent) {
        this.quoteContent = quoteContent;
    }

}
